var t = getApp();

Component({
    properties: {
        goodsId: {
            type: null
        }
    },
    data: {
        projects: [],
        appointmentLang: ""
    },
    lifetimes: {
        attached: function() {
            this.getProject();
            try {
                var t = wx.getStorageSync("yz_basic_info");
                t && this.setData({
                    appointmentLang: t.lang.appointment
                });
            } catch (t) {
                console.log(t);
            }
        }
    },
    methods: {
        getProject: function() {
            var e = this, o = t.getNetAddresss("plugin.appointment.frontend.project.get-list-by-goods-id");
            t._postNetWork({
                url: o,
                data: {
                    goods_id: e.data.goodsId
                },
                success: function(t) {
                    var o = t.data;
                    1 == o.result ? e.setData({
                        projects: o.data
                    }) : (wx.showToast({
                        title: o.msg,
                        icon: "none"
                    }), console.log(o.msg));
                }
            });
        },
        goProjectDetails: function(t) {
            var e = this, o = t.currentTarget.dataset.key, a = wx.getStorageSync("address-point").point;
            a ? wx.navigateTo({
                url: "/packageE/appointment/ProjectDetails/ProjectDetails?project_id=" + o + "&point=" + JSON.stringify(a)
            }) : wx.getLocation({
                type: "gcj02",
                success: function(t) {
                    var s = t.latitude, n = t.longitude;
                    a = e._setaddressData({
                        lat: s,
                        lng: n
                    }, o);
                }
            });
        },
        _setaddressData: function(e, o) {
            var a = this;
            t.getReverseGeocoder(e.lat, e.lng).then(function(s) {
                a.setData({
                    "point.lat": e.lat,
                    "point.lng": e.lng
                });
                var n = s, i = n.formatted_addresses.recommend;
                a.setData({
                    address: n.address,
                    title: i,
                    city: t._isTextEmpty(n.address_component.city) ? n.address_component.province : n.address_component.city
                }), wx.navigateTo({
                    url: "/packageE/appointment/ProjectDetails/ProjectDetails?project_id=" + o + "&point=" + JSON.stringify(a.data.point)
                });
            }).catch(function(t) {
                console.log(t);
            });
        },
        gotoProjects: function() {
            this.setData({
                showProjects: !0
            });
        },
        ProjectsClose: function(t) {
            this.setData({
                showProjects: !1
            });
        }
    }
});